package com.bk.bands.template;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlType;

import com.bk.bands.model.Field;
import com.google.common.collect.ForwardingCollection;


@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
@XmlType(name = "fields", namespace = "http://com.bk.docs", propOrder = {
    "content"
})
public class XmlFields
{
   protected List<Field> fields = new LinkedList<Field>();

   protected ForwardingCollection<XmlField> xmlFieldsDecorator = new ForwardingCollection<XmlField>()
   {
      private List<XmlField> xmlFields = new LinkedList<XmlField>();
      @Override
      protected List<XmlField> delegate()
      {
         return xmlFields;
      }

       public boolean add(XmlField element)
       {
          fields.add(element.getField());
          return super.add(element);
       }
   };

   public List<Field> getFields()
   {
      return fields;
   }

   @XmlAnyElement(lax = true)
   public Collection<XmlField> getContent()
   {
       return xmlFieldsDecorator;
   }

}
